package com.base.cn.platform.os.service.manage.op.coupon;

import com.base.cn.platform.os.entity.op.coupon.OpCoupon;
import com.base.cn.platform.os.service.FeignAuthConfig;
import com.base.cn.platform.os.service.manage.BaseService;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@FeignClient(name = BaseService.appName , configuration = FeignAuthConfig.class)
public interface OpCouponService extends BaseService {

    /**
     * 获取针对用户可以领取的优惠券
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/op/findForUsersCouponList")
    Map<String,Object> findForUsersCouponList(@RequestParam("userId") BigDecimal userId);

    /**
     * 用户领取优惠券
     * @param couponIds 优惠券ID串
     * @param userId 用户ID
     * @return Map<String,Object>
     */
    @RequestMapping(contextPath + "/op/couponReceive")
    Map<String,Object> couponReceive(@RequestParam("couponIds") String couponIds,
                                            @RequestParam("userId") BigDecimal userId);

    /**
     * 获取课程详情可以领取的优惠券列表
     * @param courseId 课程ID
     * @param userId 用户ID
     * @return List<OpCoupon>
     */
    @RequestMapping(contextPath + "/op/getCourseCouponList")
    List<OpCoupon> getCourseCouponList(@RequestParam("courseId") BigDecimal courseId,
                                       @RequestParam(value = "userId",required = false,defaultValue = "0") BigDecimal userId);

    /**
     * 搜索课程分页列表
     * @param opCoupon
     * @param currentPage
     * @return
     */
    @RequestMapping(contextPath + "/op/queryOpCouponListPage")
    Map<String,Object> queryOpCouponListPage(@RequestBody Map<String, Object> opCoupon,
                                             @RequestParam("currentPage") Integer currentPage,
                                             @RequestParam("subjectDate") boolean subjectDate,
                                             @RequestParam("courseDate") boolean courseDate,
                                             @RequestParam("openCourseDate") boolean openCourseDate,
                                             @RequestParam("endTimeDay") boolean endTimeDay);


    /**
     * 搜索课程列表
     * @param opCoupon
     * @return
     */
    @RequestMapping(contextPath + "/op/queryOpCouponList")
    List<Map<String,Object>> queryOpCouponList(@RequestBody Map<String, Object> opCoupon,
                                               @RequestParam("subjectDate") boolean subjectDate,
                                               @RequestParam("courseDate") boolean courseDate,
                                               @RequestParam("openCourseDate") boolean openCourseDate,
                                               @RequestParam("endTimeDay") boolean endTimeDay);

    /**
     * 添加优惠券
     * @param coupon
     * @return
     */
    @RequestMapping(contextPath + "/op/saveOpCoupon")
    Map<String,Object> saveOpCoupon(@RequestBody Map<String, Object> coupon);


    /**
     * 修改状态
     * @param couponIds
     * @param status
     * @return
     */
    @RequestMapping(contextPath + "/op/updateOpCouponStatus")
    Map<String,Object> updateOpCouponStatus(@RequestParam("couponIds") String couponIds,
                                            @RequestParam("status") Integer status);

    /**
     * 搜索优惠券根据Id
     * @param id
     * @param subjectDate
     * @param courseDate
     * @param openCourseDate
     * @return
     */
    @RequestMapping(contextPath + "/op/queryOpCouponById")
    Map<String,Object> queryOpCouponById(@RequestParam("id") BigDecimal id,
                                         @RequestParam("subjectDate") boolean subjectDate,
                                         @RequestParam("courseDate") boolean courseDate,
                                         @RequestParam("openCourseDate") boolean openCourseDate,
                                         @RequestParam("endTimeDay") boolean endTimeDay);

    /**
     * 赠送Coupon优惠券
     * @param userIds
     * @return
     */
    @RequestMapping(contextPath + "/op/presentOpCoupon")
    Map<String,Object> presentOpCoupon(@RequestParam("userIds") String userIds,
                                       @RequestParam("couponId") BigDecimal couponId);


    /**
     * 优惠券导出
     * @param opCoupon
     * @return
     * @throws IOException
     */
    @RequestMapping(contextPath + "/op/downloadExcelOpCouponCodeList")
    ResponseEntity<byte[]> downloadExcelOpCoupon(@RequestBody Map<String, Object> opCoupon) throws IOException;

}
